package com.test5;

public class Main {
	public static void main(String[] args) {
		test2();
	}

	/****
	 * 测试停止线程
	 */
	private static void test1() {
		StopThread stopThread1 = new StopThread();
		Thread thread1 = new Thread(stopThread1);
		Thread thread2 = new Thread(stopThread1);
		thread1.start();
		thread2.start();
		int i = 0;
		while (true) {
			System.out.println("thread main..");
			if (i == 300) {
				thread1.interrupt();
				thread2.interrupt();
				break;
			}
			i++;
		}

	}
	
	/*****
	 * 测试join
	 */
	public static void  test2() {
		JoinThread joinThread = new JoinThread();
		Thread t1 = new Thread(joinThread);
		//Thread t2 = new Thread(joinThread);
		t1.start();
		//t2.start();
		try {
       //其他线程变为等待状态，等t1线程执行完成之后才能执行join方法。
			t1.join();
		} catch (Exception e) {

		}
		for (int i = 0; i < 100; i++) {
			System.out.println("main ---i:" + i);
		}
	}
	 
}
